sha256

Hashing a string with Sha256

大兔子大兔子 提交于 2019-11-26 11:47:57
问题 I try to hash a string using SHA256, I\'m using the following code: using System; using System.Security.Cryptography; using System.Text; public class Hash { public static string getHashSha256(string text) { byte[] bytes = Encoding.Unicode.GetBytes(text); SHA256Managed hashstring = new SHA256Managed(); byte[] hash = hashstring.ComputeHash(bytes); string hashString = string.Empty; foreach (byte x in hash) { hashString += String.Format(\"{0:x2}\", x); } return hashString; } } However, this code

Digital signature in c# without using BouncyCastle

一笑奈何 提交于 2019-11-26 11:42:38
问题 Without using 3rd party BouncyCastle library, is there a way to read a custom private key and sign the message ? (sha256 hash+encryption using private key) 回答1: Technically, yes. Depending on what kind of key you have the answer gets more tricky. Edit (2019-Oct): .NET Core 3.0 has built-in support for all of these formats, in their DER-encoded (vs PEM-encoded) forms. I'm adding the .NET Core 3.0+ answers after a sub-heading within each file format. PKCS#8 PrivateKeyInfo (PEM "BEGIN PRIVATE

Java openssl encryption / decryption key generation [duplicate]

对着背影说爱祢 提交于 2019-11-26 11:28:42
问题 This question already has answers here : How to decrypt file in Java encrypted with openssl command using AES? (3 answers) AES 256 Encryption Issue (1 answer) Closed 3 years ago . I\'m using Java 8 and I\'m attempting to emulate the following openssl calls with Java. Encrypt: echo -n \'hello world\' | openssl enc -a -aes-256-cbc -md sha256 -pass pass:97DE:4F76 U2FsdGVkX18PnO/NLSxJ1pg6OKoLyZApMz7aBRfKhJc= Decrypt: echo U2FsdGVkX18PnO/NLSxJ1pg6OKoLyZApMz7aBRfKhJc= | openssl enc -d -a -aes-256

How to hash some string with sha256 in Java?

断了今生、忘了曾经 提交于 2019-11-26 10:05:13
How to hash some string with sha256 in Java ? Does anybody know any free library for this ? Jon Skeet SHA-256 isn't an "encoding" - it's a one-way hash. You'd basically convert the string into bytes (e.g. using text.getBytes(StandardCharsets.UTF_8) ) and then hash the bytes. Note that the result of the hash would also be arbitrary binary data, and if you want to represent that in a string, you should use base64 or hex... don't try to use the String(byte[], String) constructor. e.g. MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(text.getBytes

How can I compute a SHA-2 (ideally SHA 256 or SHA 512) hash in iOS?

≡放荡痞女 提交于 2019-11-26 08:58:17
问题 The Security services API doesn\'t appear to allow me to compute a hash directly. There are plenty of public domain and liberally licensed versions available, but I\'d rather use a system library implementation if possible. The data is accessible via NSData, or plain pointers. The cryptographic strength of the hash is important to me. SHA-256 is the minimum acceptable hash size. 回答1: This is what I'm using for SHA1: #import <CommonCrypto/CommonDigest.h> + (NSData *)sha1:(NSData *)data {

Mismatch Detected for &#39;RuntimeLibrary&#39;

不问归期 提交于 2019-11-26 07:56:56
问题 I downloaded and extracted Crypto++ in C:\\cryptopp. I used Visual Studio Express 2012 to build all the projects inside (as instructed in readme), and everything was built successfully. Then I made a test project in some other folder and added cryptolib as a dependency. After that, I added the include path so I can easily include all the headers. When I tried to compile, I got an error about unresolved symbols. To remedy that, I added C:\\cryptopp\\Win32\\Output\\Debug\\cryptlib.lib to link

How to use OpenSSL&#39;s SHA256 functions

早过忘川 提交于 2019-11-26 06:46:27
问题 I\'m writing a program to get myself acquainted with OpenSSL, libncurses, and UDP networking. I decided to work with OpenSSL\'s SHA256 to become familiar with industry encryption standards, but I\'m having issues with getting it working. I\'ve isolated the error to the linking of OpenSSL with the compiled program. I\'m working on Ubuntu 12.10, 64 bit. I have the package libssl-dev installed. Take, for instance, the C++ main.cpp: #include <iostream> #include <sstream> #include <string>

Obtain SHA-256 string of a string

风格不统一 提交于 2019-11-26 06:03:59
问题 I have some string and I want to hash it with the SHA-256 hash function using C#. I want something like this: string hashString = sha256_hash(\"samplestring\"); Is there something built into the framework to do this? 回答1: The implementation could be like that public static String sha256_hash(String value) { StringBuilder Sb = new StringBuilder(); using (SHA256 hash = SHA256Managed.Create()) { Encoding enc = Encoding.UTF8; Byte[] result = hash.ComputeHash(enc.GetBytes(value)); foreach (Byte b

SHA1 vs md5 vs SHA256: which to use for a PHP login?

若如初见. 提交于 2019-11-26 05:54:58
问题 I\'m making a php login, and I\'m trying to decide whether to use SHA1 or Md5, or SHA256 which I read about in another stackoverflow article. Are any of them more secure than others? For SHA1/256, do I still use a salt? Also, is this a secure way to store the password as a hash in mysql? function createSalt() { $string = md5(uniqid(rand(), true)); return substr($string, 0, 3); } $salt = createSalt(); $hash = sha1($salt . $hash); 回答1: Neither. You should use bcrypt . The hashes you mention are

K8s Ingress Nginx 支持 Socket.io

馋奶兔 提交于 2019-11-26 04:57:01
Ingress 及 Ingress Controller 简介 Ingress :是 k8s 资源对象 ,用于对外暴露服务,该资源对象定义了不同主机名(域名)及 URL 和对应后端 Service(k8s Service)的绑定,根据不同的路径路由 http 和 https 流量。 Ingress Contoller :是一个 pod服务 ,封装了一个 Web前端负载均衡器 ,同时在其基础上实现了 动态感知Ingress 并根据Ingress的定义动态生成 前端web负载均衡器的配置文件 ,比如 Nginx Ingress Controller 本质上就是一个 Nginx ,只不过它能根据 Ingress 资源的定义动态生成 Nginx 的配置文件,然后 动态 Reload 。 Ingress Controller 工作架构 借用 traefik 官方的图 Ingress Nginx 部署 下面是根据官方yaml文件基础上修改 apiVersion: v1 kind: Namespace metadata: name: ingress-nginx labels: app.kubernetes.io/name: ingress-nginx app.kubernetes.io/part-of: ingress-nginx --- kind: ConfigMap apiVersion: