encryption

RSA-OAEP SHA-512 Encrypt / Decrypt from Javascriptwebcrypt api to PHP openssl?

痴心易碎 提交于 2021-02-18 16:57:51
问题 I've been rather busy trying to get a secure exchange established between a browserclient, using the webcrypto api and PHP server using openssl. I've broken down things as much as I can. I wrote some javascript to generate a keypair, print out the values private and public, encrypt a simple string and print it out as well. I've copied the values straight to a simple php script. Trying to decode it with the values from the javascipt. Encoding and decoding works properly in the javascript (as

Encrypt video on the fly from android camera

百般思念 提交于 2021-02-18 11:14:26
问题 I want to encrypt video on the fly that android camera captures. So I need to tell android MediaRecorder to write it video stream to my CipherOutputStream . The problem is MediaRecorder.setOutputFile() method accepts only FileDescriptor and there is no way to get encrypting file descriptor from CipherOutputStream. So my question is how can I either emulate FileDescriptor to receive data writes and do encryption manually or somehow convince MediaRecorder to stream video into CipherOutputStream

AES use same IV for encryption and decryption

馋奶兔 提交于 2021-02-18 08:46:13
问题 I'm having some issues with my code whereby I am not using the same IV for encryption and decryption. I know in order to do this correctly I have to write the IV to my output file before the data however I am struggling implementing this. Could anyone help me with this issue? Edited code code again to show full scope public class TestFileEncryption { private static void mainCrypto(int cipherMode, File inputFile, File outputFile) throws Exception{ //Let the user enter the key they wish to use

How to store secretKey in KeyStore and retrieve it

一个人想着一个人 提交于 2021-02-18 08:45:08
问题 I'm currently developing an android application but i'm expecting some issues due to storage and retrieving of a SecretKey into the Keystore This is my code: Here I generate the SecretKey and then save it into KeyStore, and use it to encrypt my data try { KeyStore keyStore=null; keyStore= KeyStore.getInstance(KeyStore.getDefaultType()); char[] passwordKS="network".toCharArray(); SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); sr.setSeed("any data used as random seed".getBytes());

How to export symmetric encryption key?

情到浓时终转凉″ 提交于 2021-02-18 08:41:11
问题 I'm trying to implement the javax.crypto encryption between my apps (through intnets). I follow this (accepted answer): https://stackoverflow.com/questions/4319496/how-to-encrypt-and-decrypt-data-in-java .The problem is as I understood I need to have the same SecretKeySpec key in both of my apps in order to encrypt/decrypt the data. I have no idea how to export it (as a String or anything) and then hardcode it in both of my apps. 回答1: You can export a SecretKey using the getEncoded() method.

encrypt and encode URL parameters spring mvc

送分小仙女□ 提交于 2021-02-18 07:57:08
问题 I am writing a Spring mvc app and it needs to send an email with a link and encrypted params. The user will click on the link and I need to decrypt the params in the new page. So I am writing a util class to encrypt and decrypt along with encoding and decoding the parameters. When I run my stand alone java class(using for testing) - I get the following error when the decryption is called(encrypting, encoding, decoding works fine). java.security.InvalidAlgorithmParameterException: Wrong IV

Read DER private key in C# using BouncyCastle

家住魔仙堡 提交于 2021-02-18 07:50:09
问题 I am trying to read an RSA private key into .Net using BouncyCastle to test data I have previously encrypted. The encrypted data is working fine using the public key and Bouncy Castle and I have also used the same private key as below (which is DER format) to successfully decrypt my data in a PHP application but I don't know why I can't create the private key in .Net to do the same thing: byte[] privatekey = File.ReadAllBytes(@"C:\Users\Luke\privkey.der"); var rsaKeyParameters =

SHA algorithm generates each time unique hash string for a same key

陌路散爱 提交于 2021-02-18 03:34:26
问题 I know there are lots lots of articles available about hashing and encryption algorithm. I have figure it out from them that use hashing function instead of encryption to store password in the database . So I decided to use SHA-256 algorithm to generate hash key and I am storing that hash key into my server database instead of plain password. Now I am really not able to understand how I should use it, because each time I am passing the same password to generate SHA key it gives me different

Sending email from Python using STARTTLS

心不动则不痛 提交于 2021-02-17 21:59:47
问题 I want to send emails with a Python script by using Python's smtplib. The script should only send the email, if an encrypted connection to the server can be established. To encrypt the connection to port 587 I want to use STARTTLS. Using some examples I have written the following code: smtp_server = smtplib.SMTP(host, port=port) context = ssl.create_default_context() smtp_server.starttls(context) smtp_server.login(user, password) smtp_server.send_message(msg) msg, host, port, user, password