encryption

how to create a random generated alphabet in Java

佐手、 提交于 2021-02-08 12:18:51
问题 Looking to create a randomly generated alphabet for a substitution cipher. My idea was something like this. char randomChar = (char) (97 + r.nextInt(25)); However this will cause repetition of letters. Going through the char array and seeing if the letter is already present seems inefficient also. edit: I was too vague in my request and see this now. Here is the full question I am trying to solve. The alphabet must also contain the space button character e.g ' '. Write a Java program which

Caesar Cipher work

ぐ巨炮叔叔 提交于 2021-02-08 12:07:17
问题 firstly, i'm sorry for my horrible english, i'm french (yeah you can blame me ahah :P), it's my first time on this forum, i'm coming in stackoverflow because lot of people said me "go to stackoverflow if you need help". So, i need help on Javascript, in school, teachers asking to me and others, to create "Le chiffre de César", i think it's means in english "Caesar_cipher", then: HTML: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title

Caesar Cipher work

久未见 提交于 2021-02-08 12:05:02
问题 firstly, i'm sorry for my horrible english, i'm french (yeah you can blame me ahah :P), it's my first time on this forum, i'm coming in stackoverflow because lot of people said me "go to stackoverflow if you need help". So, i need help on Javascript, in school, teachers asking to me and others, to create "Le chiffre de César", i think it's means in english "Caesar_cipher", then: HTML: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title

C# Replace all characters in string with value of character key in dictionary

白昼怎懂夜的黑 提交于 2021-02-08 11:37:03
问题 hi i have this dictionary Dictionary<char, string> keys = new Dictionary<char, string>(); keys.Add("a", "23"); keys.Add("A", "95"); keys.Add("d", "12"); keys.Add("D", "69"); and for example this string string text = "Dad"; i want to encrypt the string with dictionary keys and values! the final encrypted string will be: 692312 anyone can help?! 回答1: I suggest using Linq and string.Concat : // Dictionary<string, string> - actual keys are strings Dictionary<string, string> keys = new Dictionary

C# Replace all characters in string with value of character key in dictionary

六眼飞鱼酱① 提交于 2021-02-08 11:35:09
问题 hi i have this dictionary Dictionary<char, string> keys = new Dictionary<char, string>(); keys.Add("a", "23"); keys.Add("A", "95"); keys.Add("d", "12"); keys.Add("D", "69"); and for example this string string text = "Dad"; i want to encrypt the string with dictionary keys and values! the final encrypted string will be: 692312 anyone can help?! 回答1: I suggest using Linq and string.Concat : // Dictionary<string, string> - actual keys are strings Dictionary<string, string> keys = new Dictionary

JSEncrypt(js) encrypt, but python cannot decrypt

佐手、 提交于 2021-02-08 09:14:05
问题 I'm trying RSA encrypt text with JSEncrypt(javascript) and decrypt with python crypto (python3.7). Most of the time, it works. But sometimes, python cannot decrypt. const encrypt = new JSEncrypt() encrypt.setPublicKey(publicKey) encrypt.encrypt(data) from base64 import b64decode from Crypto.Cipher import PKCS1_v1_5 as Cipher_PKCS1_v1_5 from Crypto.PublicKey import RSA crypt_text = "J9I/IdsSGZqrQ5XBTlDrze5+U3otrGEGn7J7f330/tbIpdPNwu9k5gCh35HJHuRF6tXhbOD9XbHS6dGXwRdj0KNSWa43tDQMyGp

JSEncrypt(js) encrypt, but python cannot decrypt

两盒软妹~` 提交于 2021-02-08 09:07:23
问题 I'm trying RSA encrypt text with JSEncrypt(javascript) and decrypt with python crypto (python3.7). Most of the time, it works. But sometimes, python cannot decrypt. const encrypt = new JSEncrypt() encrypt.setPublicKey(publicKey) encrypt.encrypt(data) from base64 import b64decode from Crypto.Cipher import PKCS1_v1_5 as Cipher_PKCS1_v1_5 from Crypto.PublicKey import RSA crypt_text = "J9I/IdsSGZqrQ5XBTlDrze5+U3otrGEGn7J7f330/tbIpdPNwu9k5gCh35HJHuRF6tXhbOD9XbHS6dGXwRdj0KNSWa43tDQMyGp

Decrypt AES-256-CFB in PHP with openssl instead mcrypt

独自空忆成欢 提交于 2021-02-08 08:59:25
问题 The function below correctly decrypt the data in php5 function decrypt_mcrypt($key, $str) { $str = base64_decode($str); $iv = substr($str, 0, 16); $str = substr($str, 16); return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_CFB, $iv); } I tried to use openssl instead of mcrypt (in php7), but got garbage on the output. function decrypt_openssl($key, $str) { $str = base64_decode($str); $iv = substr($str, 0, 16); $str = substr($str, 16); return openssl_decrypt($str, 'AES-256-CFB',

c# equivalent of “java.security.spec.RSAPublicKeySpec” and “java.security.PublicKey”

北城以北 提交于 2021-02-08 08:48:21
问题 I'm developing a new version in c# of an existing java application. The existing application uses RSA encryption with java.security.spec.* and boncycastle api. I'm looking for equivalent code in c# for the java below code: public static java.security.PublicKey getKey ( org.bouncycastle.asn1.x509.RSAPublicKeyStructure rsaPublicKey ) { java.security.KeyFactory keyFactory = KeyFactory.getInstance("RSA"); java.security.spec.RSAPublicKeySpec keySpec = new RSAPublicKeySpec( rsaPublicKey.getModulus(

Converting .Net decryption to Java

▼魔方 西西 提交于 2021-02-08 08:23:51
问题 Currently I'm working on a project where they use AES encryption with RFC2898 derived bytes. This the decryption method that I've provided. Now I need to implement it in java. private string Decrypt(string cipherText) { string EncryptionKey = "MAKV2SPBNI657328B"; cipherText = cipherText.Replace(" ", "+"); byte[] cipherBytes = Convert.FromBase64String(cipherText); using (Aes encryptor = Aes.Create()) { Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61