aes

Why is AES_DECRYPT returning null?

流过昼夜 提交于 2019-11-29 07:30:00
I've found similar questions, but no clear answer for this question. I have this table: CREATE DATABASE testDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE testTable ( firstName binary(32) not null, lastName binary(32) not null /* Other non-binary fields omitted */ ) engine=INNODB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; This statement executes just fine: INSERT INTO testTable (firstName) VALUES (AES_ENCRYPT('Testname', 'test')); But, this returns NULL: SELECT AES_DECRYPT(firstName, 'test') FROM testTable; Why does this return NULL? Fwiw, this returns "testValue"

Is it possible to find key to decrypt ciphertext by having the original plain text?

余生长醉 提交于 2019-11-29 07:27:14
I have plaintext P and ciphertext C, is it possible to find K key, by which P was encrypted. AES is used to encrypt. This is called a known-plaintext attack . Modern ciphers such as AES are not vulnerable to these attacks. Depends how you define "Possible". It is generally understood, for the moment, to be an impractical task. That said, storing plaintext values with their encrypted counterparts is never recommended. especially if you do this for many sets of plaintext/ciphertext pairs, you increase the amount of information available to the attacker and weaken the encryption. 来源: https:/

区块链原理之密码技术(一)

吃可爱长大的小学妹 提交于 2019-11-29 07:27:13
前言: 由于近来区块链概念的大火,使我认真阅读完Andreas M Antonopoulos大神的《精通⽐特币第二版》一书,按照我的阅读理解,比特币技术没有什么颠覆性的技术革新,它更多的是前人技术的叠加,然后利用了人性贪婪这一特性而形成链式效应,最后成功。本文不对区块链,或者说比特币进行概况性的介绍,而是讲述区块链所必须使用的密码技术原理。由于水平有限,希望能够写明白。 第一章 什么是密码技术 我们举个例子,小强要发一份电子邮件给小红,电子邮件的内容是:“今天晚上6点,天河城吃饭,不见不散!”,但是网络中一个的黑客小白,也是小强的情敌,他利用网络抓包工具窃听小强与小红的网络链路,截取了邮件内容。如下图: 那么,小白提前知道了小强与小红的约会,他就可以做很多事,至于做什么事就不在本文讨论的范围了。小强如何防止让小白知道他的约会呢?有一个办法,把“今天晚上6点,天河城吃饭,不见不散!”这句话加密,让小白截取了也看不明白,然后与小红预先约定的密码,小红收到加密的信息后使用预先约定的密码解密,还原出“今天晚上6点,天河城吃饭,不见不散!”这个约会。如下图: 这是一个最简单的加解密模型,小强通过AES算法,以及他和小红约定的密码(密码是他们两个人的生日连接,如“1999111120000520”),这个密码在计算机术语就叫密钥,AES算法就是一种数学运算规则,我们把密钥和算法称为密码技术。

Using AES encryption in .NET - CryptographicException saying the padding is invalid and cannot be removed

梦想的初衷 提交于 2019-11-29 07:22:44
I wrote some AES encryption code in C# and I am having trouble getting it to encrypt and decrypt properly. If I enter "test" as the passphrase and "This data must be kept secret from everyone!" I receive the following exception: System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) at System.Security.Cryptography.RijndaelManagedTransform

How can I use ConvertTo-SecureString

旧时模样 提交于 2019-11-29 07:05:59
Let's say I need to do this in Powershell: $SecurePass = Get-Content $CredPath | ConvertTo-SecureString -Key (1..16) [String]$CleartextPass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($CredPass)); The content of $CredPath is a file that contains the output of ConvertFrom-SecureString -Key (1..16). How do I accomplish the ConvertTo-SecureString -key (1..16) portion in C#/.NET? I know how to create a SecureString , but I'm not sure how the encryption should be handled. Do I encrypt each character using AES, or decrypt the string and

Rewrite Rijndael 256 C# Encryption Code in PHP

久未见 提交于 2019-11-29 06:06:21
I have an encryption/decryption algorithm written in C# - I need to be able to produce the same encryption in PHP so I can send the encrypted text over HTTP to be decrypted on the C# side. Here is the C# code for the encryption. this.m_plainText = string.Empty; this.m_passPhrase = "passpharse"; this.m_saltValue = "saltvalue"; this.m_hashAlgorithm = "SHA1"; this.m_passwordIterations = 2; this.m_initVector = "1a2b3c4d5e6f7g8h"; this.m_keySize = 256; public string Encrypt() { string plainText = this.m_plainText; string passPhrase = this.m_passPhrase; string saltValue = this.m_saltValue; string

Encrypting 16 bytes of UTF8 with SecKeyWrapper breaks (ccStatus == -4304)

对着背影说爱祢 提交于 2019-11-29 05:13:24
I'm using Apple's SecKeyWrapper class from the CryptoExercise sample code in the Apple docs to do some symmetric encryption with AES128. For some reason, when I encrypt 1-15 characters or 17 characters, it encrypts and decrypts correctly. With 16 characters, I can encrypt, but on decrypt it throws an exception after the CCCryptorFinal call with ccStatus == -4304 , which indicates a decode error. (Go figure.) I understand that AES128 uses 16 bytes per encrypted block, so I get the impression that the error has something to do with the plaintext length falling on the block boundary. Has anyone

Reading from a cryptostream to the end of the stream

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 05:06:24
I'm having some trouble with the code below. I have a file in a temporary location which is in need of encryption, this function encrypts that data which is then stored at the "pathToSave" location. On inspection is does not seem to be handling the whole file properly - There are bits missing from my output and I suspect it has something to do with the while loop not running through the whole stream. As an aside, if I try and call CryptStrm.Close() after the while loop I receive an exception. This means that if I attempt to decrypt the file, I get a file already in use error! Tried all the

【R】调整ggplot图例大小

风格不统一 提交于 2019-11-29 04:45:35
图例太多时,会挤压正图,显得正图展示区域很小,这时有必要缩小图例。 ################# # 减小ggplot图例 ################# library(ggplot2) p <- ggplot(mtcars, aes(drat, mpg, color = factor(gear), shape = factor(vs))) + geom_point(size = 2) + theme_classic() + theme(legend.position = c(0.1, 0.7)) p # Overwrite given size (2) to 0.5 (super small) p <- p + guides(shape = guide_legend(override.aes = list(size = 0.5))) p p <- p + guides(color = guide_legend(override.aes = list(size = 0.5))) p p <- p + theme(legend.title = element_text(size = 3), legend.text = element_text(size = 3)) p addSmallLegend <- function(myPlot, pointSize = 0.5,

AES Encryption -Key Generation with OpenSSL

霸气de小男生 提交于 2019-11-29 04:26:11
As a reference and as continuation to the post: how to use OpenSSL to decrypt Java AES-encrypted data? I have the following questions. I am using OpenSSL libs and programming in C for encrypting data in aes-cbc-128. I am given any input binary data and I have to encrypt this. I learn that Java has a CipherParameters interface to set IV and KeyParameters too. Is there a way to generate IV and a key using openSSL? In short how could one use in a C program to call the random generator of openSSL for these purposes. Can any of you provide some docs/examples/links on this? Thanks An AES key, and an