上传到解析之前的简单图像加密

时间:2017-11-29 14:11:18

标签: java android parsing encryption

我有一个应用程序从camera intent获取照片并上传到解析服务器,当应用程序打开时,它会从解析中加载所有图像并在地图上标记它们< strong>我正在寻找的是,作为解析服务器的管理员,我能够看到所有图像的内容。所以我想知道是否有一种简单的方法可以在上传之前加密这些图像,这样当它们上传时我就不会将它们视为管理员(我不是在寻找高安全性的方式从管理员隐藏他们)。这是我的上传代码

public void takePicture(View view) {


    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File photoFile = null;
    try {
        photoFile = createImageFile();
    } catch (IOException e) {
        e.printStackTrace();
    }

    startActivityForResult(intent, 100);

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode){


        // in case of capturing image using camera
        case (100):
        {
            if (requestCode == 100 && resultCode == RESULT_OK && data != null) {

                // reduce image size so it fits inside imageview

                int targetImageViewWidth = imageView.getWidth();
                int targetImageViewHeight =imageView.getHeight();

                BitmapFactory.Options bmOptions = new BitmapFactory.Options();
                bmOptions.inJustDecodeBounds = true;
                BitmapFactory.decodeFile(mCurrentPhotoPath,bmOptions);
                int cameraImageWidth = bmOptions.outWidth;
                int cameraImageHeight = bmOptions.outHeight;

                int scaleFactor= Math.min(cameraImageWidth/targetImageViewWidth,cameraImageHeight/targetImageViewHeight);
                bmOptions.inSampleSize = scaleFactor;
                bmOptions.inJustDecodeBounds = false;

                // replacing the imageview with taken picture after scaling it down

                Bitmap photo = BitmapFactory.decodeFile(mCurrentPhotoPath,bmOptions);
                imageView.setImageBitmap(photo);

                ByteArrayOutputStream stream = new ByteArrayOutputStream();

                    photo.compress(Bitmap.CompressFormat.JPEG, 50, stream);

                    byte[] byteArray = stream.toByteArray();

                    ParseFile file = new ParseFile("image.png", byteArray);

                    ParseObject object = new ParseObject("Image");

                    object.put("image", file);
                    object.put("username", ParseUser.getCurrentUser().getUsername());
                    object.put("location", new ParseGeoPoint(ParseUser.getCurrentUser().getParseGeoPoint("location")));

0 个答案:

没有答案