public-key-encryption

How to read public key from PFX file in java

不问归期 提交于 2019-12-08 12:45:52
问题 I am able to read private key from PFX file but not public key. I am using following code to read public key. InputStream inStream = new FileInputStream(certFile); CertificateFactory cf = CertificateFactory.getInstance("X.509"); BufferedInputStream bis = new BufferedInputStream(inStream); // if (bis.available() > 0) { java.security.cert.Certificate cert = cf.generateCertificate(bis); System.out.println("This part is not getting printed in case of PFX file"); // } puk = (PublicKey) cert

How to I securely store social security numbers in a database?

左心房为你撑大大i 提交于 2019-12-08 10:19:55
问题 I'm working on a web application which the users will need to submit their social security numbers. I would like to use asymmetric keys for encryption so if the web server is compromised the private key will still be safe. The application won't be processed on the webserver. However the app needs the ability to know if the SSN is a duplicate to A not allow duplicates and B to allow users to come back to their application. Can this be done? Does it make sense to use a one way hash similar to

Calculating Eulers Totient Function for very large numbers JAVA

↘锁芯ラ 提交于 2019-12-08 08:21:15
问题 I've managed to get a version of Eulers Totient Function working, albeit one that works for smaller numbers (smaller here being smaller compared to the 1024 bit numbers I need it to calculate) My version is here - public static BigInteger eulerTotientBigInt(BigInteger calculate) { BigInteger count = new BigInteger("0"); for(BigInteger i = new BigInteger("1"); i.compareTo(calculate) < 0; i = i.add(BigInteger.ONE)) { BigInteger check = GCD(calculate,i); if(check.compareTo(BigInteger.ONE)==0) {/

open source code for RSA implementation in C/C++ (Use library or write my own) [closed]

≡放荡痞女 提交于 2019-12-08 07:21:23
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I need open source code for RSA implementation (encrypt/decrypt and others). Can anyone suggest some. Edit: Is it good to use a open source library like opessl or write it your own (Library include other redundant stuff too) 回答1: OpenSSL library is the obvious choice. CryptLib is another option, yet you need to

How to fix bad length error for DecodeRSAPrivateKey?

懵懂的女人 提交于 2019-12-08 07:21:18
问题 This question was migrated from Super User because it can be answered on Stack Overflow. Migrated 2 years ago . I'm getting this error: Bad length Object reference not set to an instance of an object. I'm using this code: public string RSASign(string data, string PhysicalApplicationPath) { RSACryptoServiceProvider rsaCsp = LoadCertificateFile(PhysicalApplicationPath); byte[] dataBytes = System.Text.Encoding.Default.GetBytes(data); byte[] signatureBytes = rsaCsp.SignData(dataBytes, "SHA256");

How to combine symmetric and asymmetric encryption?

邮差的信 提交于 2019-12-08 06:56:57
问题 When talking about asymmetric encryption it is often said that due to some reasons you should not encrypt your entire message asymmetrically, e.g. performance considerations. The usually suggested workflow is: Create a random key for symmetric encryption Encrypt the message using this random key Encrypt the random key using asymmetric encryption Send the encrypted message and the encrypted key to the recipient So far, so good. Just two questions: How do I send the encrypted message and the

How to configure Jenkins to send encrypted emails with gpg?

允我心安 提交于 2019-12-08 05:40:27
问题 I am looking for instructions on how to configure the jenkins email plugin (ext-mail) to encrypt notifications? The uncle google did not help me too much. 回答1: such feature is not out-of-box, you need custom ExtendedEmailPublisher for your needs. MimeMessage msg = createMail(mailType, build, listener); Address[] allRecipients = msg.getAllRecipients(); if (allRecipients != null) { StringBuilder buf = new StringBuilder("Sending email to:"); for (Address a : allRecipients) { buf.append(' ')

How to limit people access to my EC2 with their public key

人盡茶涼 提交于 2019-12-08 05:28:48
问题 Working on EC2 is a snap, you just download the .pem file, give it the right permissions, and you are ready to go, yet ... if you have the .pem file you have full access to the EC2 instance!! What shall I do to limit people's access to the instance in a controllable way, e.g. people pass me their public key and add it to the instance a la Github 回答1: Follow the steps in this document: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html There are 3 steps: You have to add a

How to Encrypt And decrypt UTF-8 in JAVA or Android?

丶灬走出姿态 提交于 2019-12-08 04:32:46
问题 I use This Algorithm for Encrypt and Decrypt data in android. But when use utf-8 charater ..this error is displayed : [encrypt] data not block size aligned. I use this Algorithm for Encrypt and Decrypt : https://snipt.net/raw/ee573b6957b7416f28aa560ead71c3a2/?nice my code: HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(ServerIP.frooshgah_URL); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); JSONObject json = new JSONObject(); try { json.put(

programmatically generate `d` from `p` and `q` (RSA)

孤街醉人 提交于 2019-12-08 04:26:46
问题 I have two numbers, p , and q . I know that I can get phi = (p-1)*(q-1) and that ed = 1 (mod phi) ... but I'm not sure I get what this means. I wrote some Python: p = NUM q = NUM e = NUM phi = (p-1)*(q-1) d = (1 % phi)/float(e) But I always get a decimal, and d is supposed to be an integer. what am I doing wrong? EDIT: I may just not understand RSA. Right now, I'm looking at this page: http://www.di-mgt.com.au/rsa_alg.html 回答1: Your understanding of the math is wrong. The equation ed ≡ 1 (mod