<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSecurity%2FSHA1_Secure_Hash_Algorithm</id>
		<title>Java Tutorial/Security/SHA1 Secure Hash Algorithm - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSecurity%2FSHA1_Secure_Hash_Algorithm"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Security/SHA1_Secure_Hash_Algorithm&amp;action=history"/>
		<updated>2026-04-11T01:22:55Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Security/SHA1_Secure_Hash_Algorithm&amp;diff=4346&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Security/SHA1_Secure_Hash_Algorithm&amp;diff=4346&amp;oldid=prev"/>
				<updated>2010-06-01T05:01:49Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:01, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Security/SHA1_Secure_Hash_Algorithm&amp;diff=4345&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Security/SHA1_Secure_Hash_Algorithm&amp;diff=4345&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Basic IO example using SHA1 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.ByteArrayInputStream;&lt;br /&gt;
import java.io.ByteArrayOutputStream;&lt;br /&gt;
import java.security.DigestInputStream;&lt;br /&gt;
import java.security.DigestOutputStream;&lt;br /&gt;
import java.security.MessageDigest;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    byte[] input = &amp;quot;1234567&amp;quot;.getBytes();&lt;br /&gt;
    MessageDigest hash = MessageDigest.getInstance(&amp;quot;SHA1&amp;quot;);&lt;br /&gt;
    ByteArrayInputStream bIn = new ByteArrayInputStream(input);&lt;br /&gt;
    DigestInputStream dIn = new DigestInputStream(bIn, hash);&lt;br /&gt;
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();&lt;br /&gt;
    int ch;&lt;br /&gt;
    while ((ch = dIn.read()) &amp;gt;= 0) {&lt;br /&gt;
      bOut.write(ch);&lt;br /&gt;
    }&lt;br /&gt;
    byte[] newInput = bOut.toByteArray();&lt;br /&gt;
    System.out.println(&amp;quot;in digest : &amp;quot; + new String(dIn.getMessageDigest().digest()));&lt;br /&gt;
    DigestOutputStream dOut = new DigestOutputStream( new ByteArrayOutputStream(), hash);&lt;br /&gt;
    dOut.write(newInput);&lt;br /&gt;
    dOut.close();&lt;br /&gt;
    System.out.println(&amp;quot;out digest: &amp;quot; + new String(dOut.getMessageDigest().digest()));&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Encrypt a password ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String arg[]) throws Exception {&lt;br /&gt;
    System.out.println(encrypt(&amp;quot;String&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
  public static byte[] encrypt(String x) throws Exception {&lt;br /&gt;
    java.security.MessageDigest d = null;&lt;br /&gt;
    d = java.security.MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
    d.reset();&lt;br /&gt;
    d.update(x.getBytes());&lt;br /&gt;
    return d.digest();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  PSS parameter recovery and encoding ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.security.AlgorithmParameters;&lt;br /&gt;
import java.security.Security;&lt;br /&gt;
import java.security.Signature;&lt;br /&gt;
import java.security.spec.PSSParameterSpec;&lt;br /&gt;
import org.bouncycastle.asn1.ASN1InputStream;&lt;br /&gt;
import org.bouncycastle.asn1.util.ASN1Dump;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());&lt;br /&gt;
    Signature signature = Signature.getInstance(&amp;quot;SHA1withRSAandMGF1&amp;quot;, &amp;quot;BC&amp;quot;);&lt;br /&gt;
    signature.setParameter(PSSParameterSpec.DEFAULT);&lt;br /&gt;
    AlgorithmParameters params = signature.getParameters();&lt;br /&gt;
    ASN1InputStream aIn = new ASN1InputStream(params.getEncoded(&amp;quot;ASN.1&amp;quot;));&lt;br /&gt;
    System.out.println(ASN1Dump.dumpAsString(aIn.readObject()));&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Use SHA1 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.security.DigestInputStream;&lt;br /&gt;
import java.security.MessageDigest;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  private static int BUFFER_SIZE = 32 * 1024;&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    System.out.println(&amp;quot;test.txt: &amp;quot; + md(&amp;quot;test.txt&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
  public static String md(String f) throws Exception {&lt;br /&gt;
    BufferedInputStream file = new BufferedInputStream(new FileInputStream(f));&lt;br /&gt;
    MessageDigest md = MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
    DigestInputStream in = new DigestInputStream(file, md);&lt;br /&gt;
    int i;&lt;br /&gt;
    byte[] buffer = new byte[BUFFER_SIZE];&lt;br /&gt;
    do {&lt;br /&gt;
      i = in.read(buffer, 0, BUFFER_SIZE);&lt;br /&gt;
    } while (i == BUFFER_SIZE);&lt;br /&gt;
    md = in.getMessageDigest();&lt;br /&gt;
    in.close();&lt;br /&gt;
    return new String(md.digest());&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>