ctr

How to seek in CTR mode and decrypt part of the stream?

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a question in partial decoding in cryptopp. USE AES 256 CTR; Encode source: CTR_Mode< AES >::Encryption e; e.SetKeyWithIV(key, 32, iv); string encrypt; string a = "Example text to encoding"; encrypt.clear(); StringSource s(a, true, new StreamTransformationFilter(e, new StringSink(encrypt) ) ); Decode source: CTR_Mode<AES>::Decryption d; d.SetKeyWithIV(key, 32, iv); string x; StringSource s1(encrypt, true, new StreamTransformationFilter(d, new StringSink(x) ) ); It works fine. But I don't know how decrypt only part. For example,

一个略高效的自制加解密函数

旧城冷巷雨未停 提交于 2019-12-03 07:37:24
<?php /** * Crypt class file. * * @author woondroo * @package framework * @date 2015-04-09 */ class Crypt { /** * Passport 加密函数 * * @param string 等待加密的原字串 * @param string 私有密匙(用于解密和加密) * * @return string 原字串经过私有密匙加密后的结果 */ public static function encode( $_strVal = "" , $_strKey = "" ) { // 使用随机数发生器产生 0~32000 的值并 MD5() srand((double)microtime() * 1000000); $encrypt_key = md5(rand(0, 32000)); // 变量初始化 $ctr = 0; $tmp = ''; // for 循环,$i 为从 0 开始,到小于 $_strVal 字串长度的整数 for($i = 0; $i < strlen($_strVal); $i++) { // 如果 $ctr = $encrypt_key 的长度,则 $ctr 清零 $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr; //

Paramiko: “FutureWarning: CTR mode needs counter parameter”

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to use Paramiko in Python2 for transferring files through SFTP with private SSH key but it displays this warning: /usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py:141: FutureWarning: CTR mode needs counter parameter, not IV self._cipher = factory.new(key, *args, **kwargs) In fact it sends the file to the server but can someone explain me what this warning means? Here is my code: t = paramiko.Transport((host, port)) key = paramiko.RSAKey.from_private_key_file("/path/to/key.ssh") t.connect(username="username",password

Skipping Kerberos authentication prompts with JSch [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:58:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: SFTP connection through Java asking for weird authentication 2 answers I am using the Connect() method in the Ssh Java class below in order to connect to a server using SSH (JSch) and running a command in the server. The problem is that when running Connect() the server prompts the next messages: Kerberos username [********]: Kerberos password for ********: And in order to continue running I need to manually press the Enter key twice, one for the user name and one for the password. I have tried to

jquery keypress event for cmd+s AND ctrl+s

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using one of the examples from a previous question I have: $(window).keypress(function(event) { if (!(event.which == 115 && event.ctrlKey) && !(event.which == 19)) return true; $("form input[name=save]").click(); event.preventDefault(); return false; }); Is it also possible to change this to work for the Mac cmd key? I have tried (!(event.which == 115 && (event.cmdKey || event.ctrlKey)) && !(event.which == 19)) but this didn't work. 回答1: Use the event.metaKey to detect the Command key $(document).keypress(function(event) { if (event.which ==

Paramiko AuthenticationException issue

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am having a problem connecting to a device with a Paramiko (version 1.7.6-2) ssh client: $ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import paramiko >>> ssh = paramiko.SSHClient() >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) >>> ssh.connect("123.0.0.1", username="root", password=None) Traceback (most recent call last): File " ", line 1, in File "/usr/lib/pymodules/python2.6/paramiko/client.py", line 327, in

AES 128 bit CTR partial file decryption with PHP

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is not a duplicate post because I have looked everywhere and I can't find an answer to this. Its about partial decryption. Not full. I have a good knowledge of PHP but little knowledge about cryptography. I know the key and the iv of the crypted file. The file is decrypting fine as whole but the real issue arises when I try to decrypt the partial file from the middle. It decrypts fine when I try to decrypt the first 128kb of the file or 256kb or any length from the beginning of the file. but when I start from the middle, it does not

AES CTR 256 Encryption Mode of operation on OpenSSL

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char ivec[AES_BLOCK_SIZE], unsigned char ecount_buf[AES_BLOCK_SIZE], unsigned int *num); Hi Caf I really appreciate your quick answer it has been really useful, and defenetly the best example I have found on the web. I am trying to open a file with undetermined length, encrypt it and write another file with the ciphertext generated, then open the ciphered file and recover the plaintext. I need to use a file of a

JSchException: Algorithm negotiation fail diffie-hellman-group14-sha1

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know this has been asked a few times but I have tried many of the accepted solutions already given. I am creating a simple SSH tunnel using JSch. and I keep getting this error along with this in the logs: INFO: diffie-hellman-group14-sha1 is not available. I have already added the Java unlimited policy files to the correct folder and I have added this algorithm to the KexAlgorithms section in the sshd_config file. Below is the full log breakdown. INFO: Connecting to xx.xx.xxx.xxx port 22 INFO: Connection established INFO: Remote version

“Auth fail” in jsch-0.1.42 with Java 1.4.2

匿名 (未验证) 提交于 2019-12-03 00:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this simple Java program that uses Jsch to connect to an SFTP server. The connection fails with an "Auth fail" exception on Java 1.4.2, but it connects flawlessly on Java 1.7. try { JSch jsch = new JSch(); jsch.setKnownHosts(KNOWN_HOSTS_PATH); jsch.addIdentity(PRIVATE_KEY_PATH, PASSPHRASE); Session session = jsch.getSession(USERNAME, HOSTNAME, 22); session.connect(2500); Channel channel = session.openChannel("shell"); channel.setInputStream(System. in ); channel.setOutputStream(System.out); channel.connect(); } catch (Exception e) { e