|
sha256
|
|||
---|---|---|---|
#18+
Подскажите пожалуйста как можно хешировать по алгоритму sha256? Нашла пример в нете, но если sha1 заменить на sha256, sybase ругается Invalid parameter 2 for HASH builtin function CREATE TABLE #user_info ( employee_id int NOT NULL PRIMARY KEY, user_name CHAR(80), user_pwd CHAR(80) ) INSERT INTO #user_info VALUES ( 1, 'user1', HASH( 'mypass', 'sha1' ) ) select * from #user_info ... |
|||
:
Нравится:
Не нравится:
|
|||
03.12.2019, 15:56 |
|
sha256
|
|||
---|---|---|---|
#18+
hum_i, Укажите версию сервера - ASE/ASA/IQ ... |
|||
:
Нравится:
Не нравится:
|
|||
03.12.2019, 16:40 |
|
sha256
|
|||
---|---|---|---|
#18+
Компостеров hum_i, Укажите версию сервера - ASE/ASA/IQ 16 версия ... |
|||
:
Нравится:
Не нравится:
|
|||
04.12.2019, 07:44 |
|
sha256
|
|||
---|---|---|---|
#18+
hum_i, К сожалению, ASE не поддерживает sha256. По крайней мере в 16.0 SP2 версии Можно воспользоваться советом от Rob Verschoor October 2011 I was recently contacted by an ASE user who had a requirement to store data in ASE after hashing it with SHA-256. As of version 15.0.2, ASE provides the built-in functions hash() and hashbytes() are available, but these support only SHA and SHA-1 (as well as MD5), but not SHA-256. For some reason, other hashing algorithms were not acceptable to use. Eventually though, this ASE user found a way to use SHA-256 inside ASE. How would you have solved this problem? Answer: Since ASE also supports user-defined SQL functions, you could consider implementing the SHA-256 algorithm yourself in Transact-SQL. I haven't tried this myself, but I don't immediately see a reason why this couldn't be done (you'd have to use a varchar(16384) variable as an array while calculating the algorithm). If anyone with enough spare time on his hands manages to get this working, please share the result. The more practical solution, as indeed adopted by our ASE user, is to use Java, which supports various hashing algorithms. For example, you could use the java.security.MessageDigest class ('message digest' is a more formal name for 'hashing'): import java.security.MessageDigest; String MyDataToHash = "Gotta keep this text safe! Better hash it..."; MessageDigest D = MessageDigest.getInstance("SHA-256"); D.reset(); byte[] Hashed = D.digest(MyDataToHash.getBytes("UTF-8")); You can code up a Java class with this functionality and load the class into ASE (see this page for more details on how to do that). Assuming the class name is HashSHA256 with a method named CalcSHA256, you can then do this: 1> create function sha256(s varchar(255)) returns varchar(255) 2> language java parameter style java 3> external name 'HashSHA256.CalcSHA256' 4> go ... so that finally, you can call the Java class as if it was an ASE function: 1> select sha256("MyVeryS3cretP@ssword") 2> go Presto! Obviously, using this Java workaround will likely be signficantly slower than the native ASE functions hash() and hashbytes(). But this is an interesting way of quickly borrowing some functionality already available elsewhere. ... |
|||
:
Нравится:
Не нравится:
|
|||
04.12.2019, 09:27 |
|
sha256
|
|||
---|---|---|---|
#18+
Ясно спасибо. а есть в sybase возможность дешифровки из sha1? HASH( 'mypass', 'sha1' ) - это шифрование А вот если наоборот? подскажите пожалуйста ... |
|||
:
Нравится:
Не нравится:
|
|||
05.12.2019, 09:20 |
|
sha256
|
|||
---|---|---|---|
#18+
подскажите пожалуйста а ENCRYPT/DECRYPT в 16 версии sybase есть? ... |
|||
:
Нравится:
Не нравится:
|
|||
05.12.2019, 10:06 |
|
|
start [/forum/topic.php?fid=55&fpage=1&tid=2009575]: |
0ms |
get settings: |
9ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
42ms |
get topic data: |
11ms |
get forum data: |
2ms |
get page messages: |
46ms |
get tp. blocked users: |
2ms |
others: | 253ms |
total: | 384ms |
0 / 0 |