aes

Different output encryption both CryptoJS and Java Code

Deadly 提交于 2019-12-03 09:15:42
I need to encrypt certainly string from client-side (JavaScript) and decrypt from server-side (Java), so I found CryptoJS and I write the code with the same params/configuration of mi Java Code but the output is always different, do you have any idea or what happen? I'm using CBC with NoPadding CryptoJS http://jsfiddle.net/Soldier/gCHAG/ <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"> </script> <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/pad-nopadding-min.js"></script> <script> function padString(source) { var paddingChar = '

AES Decryption: javax.crypto.BadPaddingException: pad block corrupted in Android

ⅰ亾dé卋堺 提交于 2019-12-03 09:15:38
I am stuck with a problem with AES Decryption in my android Application. I have searched a lot but unable to get the solution. Here are the steps, what i am doing. Encrypt the credit card number with my key send to the Web server. Web server Decrypt the credit card number and save it. When we fetch the credit card number from the Web service. Then web server encrypt the credit card number with the same key and send to Us. Now When we decrypt this number, it throws bad padding exception for some credit card number information. Also encrypted information is not same coming from the server, what

OpenSSL C example of AES-GCM using EVP interfaces

柔情痞子 提交于 2019-12-03 09:10:53
问题 For AES-GCM encryption/decryption, I tried this, but it has a problem. ctx = EVP_CIPHER_CTX_new(); //Get the cipher. cipher = EVP_aes_128_gcm (); #define GCM_IV "000000000000" #define GCM_ADD "0000" #define TAG_SIZE 16 #define ENC_SIZE 64 //Encrypt the data first. //Set the cipher and context only. retv = EVP_EncryptInit (ctx, cipher, NULL, NULL); //Set the nonce and tag sizes. //Set IV length. [Optional for GCM]. retv = EVP_CIPHER_CTX_ctrl (ctx, EVP_CTRL_GCM_SET_IVLEN, strlen((const char *

Decrypting data on desktop that was encrypted on android

我的梦境 提交于 2019-12-03 09:09:57
I have an app which encrypts some text strings, and then writes these to a file. The desktop version of the app is reading the file and decrypts the data. The problem is that whenever I decrypt on the desktop version , I get a "javax.crypto.BadPaddingException: Given final block not properly padded" Both the app and the desktop are using the same code: import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public class SSL { private final static String HEX = "0123456789ABCDEF";

How to map all the states of US using R with the number of crimes occurred in each state?

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am still learning about R and I want to map the States of US with the labels of number of crimes occurred in each state. I want to create the below image. I used the below code which was available online but I could not label the No of crimes. library ( ggplot2 ) library ( fiftystater ) data ( "fifty_states" ) crimes <- data . frame ( state = tolower ( rownames ( USArrests )), USArrests ) p <- ggplot ( crimes , aes ( map_id = state )) + # map points to the fifty_states shape data geom_map ( aes ( fill = Assault ), map = fifty

AES128 encryption in swift

旧街凉风 提交于 2019-12-03 08:56:09
I’ve an issue with AES-128 encryption. The encrypted string in iOS is different as compared to Android. Below is android code : public class Encryption { private static final String ALGORITHM = "AES"; private static final String UNICODE_FORMAT = "UTF8"; public static String encryptValue(String valueToEnc) { try { Key key = generateKey(); Cipher c = Cipher.getInstance(ALGORITHM); c.init(Cipher.ENCRYPT_MODE, key); byte[] encValue = c.doFinal(valueToEnc.getBytes()); String encryptedValue = new Base64().encode(encValue); String urlEncodeddata = URLEncoder.encode(encryptedValue, "UTF-8"); return

geom_bar(): stacked and dodged combined

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I seek advice on ggplot2::geom_bar(). My data contains the categories "A", "B", "Z". I want A, B as stacked bar, and Z as dodged bar next to the A, B bar . # sample data A = c(3, 4, 3, 5) B = c(2, 2, 1, 4) Z = c(1, 2, 1, 2) R = c(-2, -1, -3, 0) S = c(7,7,7,9) mydata = data.frame(cbind(A,B,Z,R,S)) dates = c("2014-01-01","2014-02-01","2014-03-01","2014-04-01") mydata$date = as.Date(dates) mydata.m = melt(mydata,id="date") names(mydata.m) = c("variable", "category","value") s = ggplot(mydata.m, aes(x=variable, fill=category)) + # bars for cat A

AES-128 CBC decryption in Python

╄→尐↘猪︶ㄣ 提交于 2019-12-03 08:54:01
I'm trying to implement this code in python (I'm new to python) and it gives me the following error: AttributeError: 'str' object has no attribute 'decode' If we remove .decode ('hex') only to avoid such error: from itertools import product from Crypto.Cipher import AES import Crypto.Cipher.AES key = ('2b7e151628aed2a6abf7158809cf4f3c').decode('hex') IV = ('000102030405060708090a0b0c0d0e0f').decode('hex') plaintext1 = ('6bc1bee22e409f96e93d7e117393172a').decode('hex') plaintext2 = ('ae2d8a571e03ac9c9eb76fac45af8e51').decode('hex') plaintext3 = ('30c81c46a35ce411e5fbc1191a0a52ef').decode('hex')

“Wrong algorithm” Error when trying to Decrypt in Java

偶尔善良 提交于 2019-12-03 08:51:52
I am first going to describe the problem which I have, and then give some background to what I am trying to do. Finally I shall paste some relevant code snippets. I am trying to implement secret key encryption/decryption using the method specified in https://stackoverflow.com/a/992413/171993 . If I use that example as-is, it works (although I did notice that I need to re-instantiate the Cipher class, otherwise the decryption produces garbage). However, in my implementation I get the following exception: java.security.InvalidKeyException: Wrong algorithm: AES or Rijndael required at com.sun

ggplot: percentile lines by group automation

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've found the dplyr %>% operator helpful with simple ggplot2 transformations (without resorting to ggproto , which is required for ggplot2 extensions ), e.g. library(ggplot2) library(scales) library(dplyr) gg.histo.pct.by.group <- function(g, ...) { g + geom_histogram(aes(y=unlist(lapply(unique(..group..), function(grp) ..count..[..group..==grp] / sum(..count..[..group..==grp])))), ...) + scale_y_continuous(labels = percent) + ylab("% of total count by group") } data = diamonds %>% select(carat, color) %>% filter(color %in% c('H', 'D')) g =