Skip to content

Commit b234278

Browse files
author
isayan
committed
Support SHAKE128/SHAKE256
1 parent 37348f6 commit b234278

File tree

10 files changed

+215
-25
lines changed

10 files changed

+215
-25
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
netbeans.org-netbeans-modules-javascript2-requirejs.enabled=true
22
release_version_major=3.0
3-
release_version_minor=8.4
3+
release_version_minor=8.5
44
netbeans.license=mit

help/help-ja.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,14 @@ <h5 id="_hashchecksum">Hash/Checksum</h5>
18841884
<dd>
18851885
<p>sha3-512によるハッシュを計算します。</p>
18861886
</dd>
1887+
<dt class="hdlist1">SHAKE128</dt>
1888+
<dd>
1889+
<p>SHAKE128によるハッシュを計算します。</p>
1890+
</dd>
1891+
<dt class="hdlist1">SHAK256</dt>
1892+
<dd>
1893+
<p>SHAK256によるハッシュを計算します。</p>
1894+
</dd>
18871895
<dt class="hdlist1">RIPEMD128</dt>
18881896
<dd>
18891897
<p>RIPEMD128によるハッシュを計算します。</p>
@@ -2424,7 +2432,7 @@ <h3 id="_version">3.10. Version</h3>
24242432
</div>
24252433
<div id="footer">
24262434
<div id="footer-text">
2427-
Last updated 2024-02-22 20:23:18 +0900
2435+
Last updated 2024-03-03 22:52:09 +0900
24282436
</div>
24292437
</div>
24302438
</body>

help/help.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,14 @@ <h5 id="_hashchecksum">Hash/Checksum</h5>
19091909
<dd>
19101910
<p>Calculate hash with sha3-512</p>
19111911
</dd>
1912+
<dt class="hdlist1">SHAKE128</dt>
1913+
<dd>
1914+
<p>Calculate hash with SHAKE128</p>
1915+
</dd>
1916+
<dt class="hdlist1">SHAK256</dt>
1917+
<dd>
1918+
<p>Calculate hash with SHAKE256</p>
1919+
</dd>
19121920
<dt class="hdlist1">RIPEMD128</dt>
19131921
<dd>
19141922
<p>Calculate hash with RIPEMD128</p>
@@ -2458,7 +2466,7 @@ <h3 id="_version">3.11. Version</h3>
24582466
</div>
24592467
<div id="footer">
24602468
<div id="footer-text">
2461-
Last updated 2024-02-22 20:22:38 +0900
2469+
Last updated 2024-03-03 22:51:14 +0900
24622470
</div>
24632471
</div>
24642472
</body>

release/YaguraExtension-v3.0.jar

1.54 KB
Binary file not shown.

src/main/help/help-ja.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,12 @@ sha3-384::
868868
sha3-512::
869869
sha3-512によるハッシュを計算します。
870870

871+
SHAKE128::
872+
SHAKE128によるハッシュを計算します。
873+
874+
SHAK256::
875+
SHAK256によるハッシュを計算します。
876+
871877
RIPEMD128::
872878
RIPEMD128によるハッシュを計算します。
873879

src/main/help/help.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,11 @@ sha3-384::
871871
sha3-512::
872872
Calculate hash with sha3-512
873873

874+
SHAKE128::
875+
Calculate hash with SHAKE128
876+
877+
SHAK256::
878+
Calculate hash with SHAKE256
874879

875880
RIPEMD128::
876881
Calculate hash with RIPEMD128

src/main/java/extend/util/external/BouncyUtil.java

Lines changed: 108 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* @author isayan
4242
*/
4343
public class BouncyUtil {
44+
4445
private final static Logger logger = Logger.getLogger(BouncyUtil.class.getName());
4546

4647
private final static BouncyCastleProvider BC_PROVIDER = new BouncyCastleProvider();
@@ -199,6 +200,98 @@ public static String toMessageDigest(String algorithm, byte[] binary, boolean up
199200
}
200201
}
201202

203+
/**
204+
* SHAKE128値の取得
205+
*
206+
* @param binary 対象バイト
207+
* @param upperCase 大文字で出力
208+
* @return ハッシュ値
209+
*/
210+
public static String toSHAKE128um(byte[] binary, boolean upperCase) {
211+
try {
212+
return toMessageDigest("SHAKE128", binary, upperCase);
213+
} catch (NoSuchAlgorithmException ex) {
214+
logger.log(Level.SEVERE, ex.getMessage(), ex);
215+
}
216+
return null;
217+
}
218+
219+
/**
220+
* SHAKE128値の取得
221+
*
222+
* @param str 対象文字列
223+
* @param upperCase 大文字で出力
224+
* @return ハッシュ値
225+
*/
226+
public static String toSHAKE128Sum(String str, boolean upperCase) {
227+
try {
228+
return toMessageDigest("SHAKE128", str, StandardCharsets.ISO_8859_1, upperCase);
229+
} catch (NoSuchAlgorithmException ex) {
230+
logger.log(Level.SEVERE, ex.getMessage(), ex);
231+
}
232+
return null;
233+
}
234+
235+
/**
236+
* SHAKE128値の取得
237+
*
238+
* @param str 対象文字列
239+
* @param charset エンコーディング
240+
* @param upperCase
241+
* @return ハッシュ値
242+
* @throws UnsupportedEncodingException
243+
*/
244+
public static String toSHAKE128Sum(String str, String charset, boolean upperCase)
245+
throws UnsupportedEncodingException {
246+
return toSHAKE128um(StringUtil.getBytesCharset(str, charset), upperCase);
247+
}
248+
249+
/**
250+
* SHAKE256値の取得
251+
*
252+
* @param binary 対象バイト
253+
* @param upperCase 大文字で出力
254+
* @return ハッシュ値
255+
*/
256+
public static String toSHAKE256um(byte[] binary, boolean upperCase) {
257+
try {
258+
return toMessageDigest("SHAKE256", binary, upperCase);
259+
} catch (NoSuchAlgorithmException ex) {
260+
logger.log(Level.SEVERE, ex.getMessage(), ex);
261+
}
262+
return null;
263+
}
264+
265+
/**
266+
* SHAKE256値の取得
267+
*
268+
* @param str 対象文字列
269+
* @param upperCase 大文字で出力
270+
* @return ハッシュ値
271+
*/
272+
public static String toSHAKE256um(String str, boolean upperCase) {
273+
try {
274+
return toMessageDigest("SHAKE256", str, StandardCharsets.ISO_8859_1, upperCase);
275+
} catch (NoSuchAlgorithmException ex) {
276+
logger.log(Level.SEVERE, ex.getMessage(), ex);
277+
}
278+
return null;
279+
}
280+
281+
/**
282+
* SHAKE256値の取得
283+
*
284+
* @param str 対象文字列
285+
* @param charset エンコーディング
286+
* @param upperCase
287+
* @return ハッシュ値
288+
* @throws UnsupportedEncodingException
289+
*/
290+
public static String toSHAKE256um(String str, String charset, boolean upperCase)
291+
throws UnsupportedEncodingException {
292+
return toSHAKE256um(StringUtil.getBytesCharset(str, charset), upperCase);
293+
}
294+
202295
/**
203296
* RIPEMD128値の取得
204297
*
@@ -210,9 +303,9 @@ public static String toRIPEMD128Sum(byte[] binary, boolean upperCase) {
210303
try {
211304
return toMessageDigest("RIPEMD128", binary, upperCase);
212305
} catch (NoSuchAlgorithmException ex) {
213-
logger.log(Level.SEVERE, ex.getMessage(), ex);
214-
return null;
306+
logger.log(Level.SEVERE, ex.getMessage(), ex);
215307
}
308+
return null;
216309
}
217310

218311
/**
@@ -227,8 +320,8 @@ public static String toRIPEMD128Sum(String str, boolean upperCase) {
227320
return toMessageDigest("RIPEMD128", str, StandardCharsets.ISO_8859_1, upperCase);
228321
} catch (NoSuchAlgorithmException ex) {
229322
logger.log(Level.SEVERE, ex.getMessage(), ex);
230-
return null;
231323
}
324+
return null;
232325
}
233326

234327
/**
@@ -257,8 +350,8 @@ public static String toRIPEMD160Sum(byte[] binary, boolean upperCase) {
257350
return toMessageDigest("RIPEMD160", binary, upperCase);
258351
} catch (NoSuchAlgorithmException ex) {
259352
logger.log(Level.SEVERE, ex.getMessage(), ex);
260-
return null;
261353
}
354+
return null;
262355
}
263356

264357
/**
@@ -273,8 +366,8 @@ public static String toRIPEMD160Sum(String str, boolean upperCase) {
273366
return toMessageDigest("RIPEMD160", str, StandardCharsets.ISO_8859_1, upperCase);
274367
} catch (NoSuchAlgorithmException ex) {
275368
logger.log(Level.SEVERE, ex.getMessage(), ex);
276-
return null;
277369
}
370+
return null;
278371
}
279372

280373
/**
@@ -303,8 +396,8 @@ public static String toRIPEMD256Sum(byte[] binary, boolean upperCase) {
303396
return toMessageDigest("RIPEMD256", binary, upperCase);
304397
} catch (NoSuchAlgorithmException ex) {
305398
logger.log(Level.SEVERE, ex.getMessage(), ex);
306-
return null;
307399
}
400+
return null;
308401
}
309402

310403
/**
@@ -319,8 +412,8 @@ public static String toRIPEMD256Sum(String str, boolean upperCase) {
319412
return toMessageDigest("RIPEMD256", str, StandardCharsets.ISO_8859_1, upperCase);
320413
} catch (NoSuchAlgorithmException ex) {
321414
logger.log(Level.SEVERE, ex.getMessage(), ex);
322-
return null;
323415
}
416+
return null;
324417
}
325418

326419
/**
@@ -349,8 +442,8 @@ public static String toRIPEMD320Sum(byte[] binary, boolean upperCase) {
349442
return toMessageDigest("RIPEMD320", binary, upperCase);
350443
} catch (NoSuchAlgorithmException ex) {
351444
logger.log(Level.SEVERE, ex.getMessage(), ex);
352-
return null;
353445
}
446+
return null;
354447
}
355448

356449
/**
@@ -365,8 +458,8 @@ public static String toRIPEMD320Sum(String str, boolean upperCase) {
365458
return toMessageDigest("RIPEMD320", str, StandardCharsets.ISO_8859_1, upperCase);
366459
} catch (NoSuchAlgorithmException ex) {
367460
logger.log(Level.SEVERE, ex.getMessage(), ex);
368-
return null;
369461
}
462+
return null;
370463
}
371464

372465
/**
@@ -395,8 +488,8 @@ public static String toTigerSum(byte[] binary, boolean upperCase) {
395488
return toMessageDigest("Tiger", binary, upperCase);
396489
} catch (NoSuchAlgorithmException ex) {
397490
logger.log(Level.SEVERE, ex.getMessage(), ex);
398-
return null;
399491
}
492+
return null;
400493
}
401494

402495
/**
@@ -411,8 +504,8 @@ public static String toTigerSum(String str, boolean upperCase) {
411504
return toMessageDigest("Tiger", str, StandardCharsets.ISO_8859_1, upperCase);
412505
} catch (NoSuchAlgorithmException ex) {
413506
logger.log(Level.SEVERE, ex.getMessage(), ex);
414-
return null;
415507
}
508+
return null;
416509
}
417510

418511
/**
@@ -441,8 +534,8 @@ public static String toGOST3411Sum(byte[] binary, boolean upperCase) {
441534
return toMessageDigest("GOST3411", binary, upperCase);
442535
} catch (NoSuchAlgorithmException ex) {
443536
logger.log(Level.SEVERE, ex.getMessage(), ex);
444-
return null;
445537
}
538+
return null;
446539
}
447540

448541
/**
@@ -457,8 +550,8 @@ public static String toGOST3411Sum(String str, boolean upperCase) {
457550
return toMessageDigest("GOST3411", str, StandardCharsets.ISO_8859_1, upperCase);
458551
} catch (NoSuchAlgorithmException ex) {
459552
logger.log(Level.SEVERE, ex.getMessage(), ex);
460-
return null;
461553
}
554+
return null;
462555
}
463556

464557
/**
@@ -487,8 +580,8 @@ public static String toWHIRLPOOLSum(byte[] binary, boolean upperCase) {
487580
return toMessageDigest("WHIRLPOOL", binary, upperCase);
488581
} catch (NoSuchAlgorithmException ex) {
489582
logger.log(Level.SEVERE, ex.getMessage(), ex);
490-
return null;
491583
}
584+
return null;
492585
}
493586

494587
/**
@@ -503,8 +596,8 @@ public static String toWHIRLPOOLSum(String str, boolean upperCase) {
503596
return toMessageDigest("WHIRLPOOL", str, StandardCharsets.ISO_8859_1, upperCase);
504597
} catch (NoSuchAlgorithmException ex) {
505598
logger.log(Level.SEVERE, ex.getMessage(), ex);
506-
return null;
507599
}
600+
return null;
508601
}
509602

510603
/**

src/main/java/yagura/view/JTransCoderTab.form

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
3030
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
3131
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
32-
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-40,0,0,4,-108"/>
32+
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-24,0,0,4,-108"/>
3333
</AuxValues>
3434

3535
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
@@ -622,7 +622,7 @@
622622

623623
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
624624
<Property name="columns" type="int" value="3"/>
625-
<Property name="rows" type="int" value="7"/>
625+
<Property name="rows" type="int" value="8"/>
626626
</Layout>
627627
<SubComponents>
628628
<Component class="javax.swing.JButton" name="btnHashMd2">
@@ -729,6 +729,22 @@
729729
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnHashSha3_512ActionPerformed"/>
730730
</Events>
731731
</Component>
732+
<Component class="javax.swing.JButton" name="btnSHAKE128">
733+
<Properties>
734+
<Property name="text" type="java.lang.String" value="SHAKE128"/>
735+
</Properties>
736+
<Events>
737+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSHAKE128ActionPerformed"/>
738+
</Events>
739+
</Component>
740+
<Component class="javax.swing.JButton" name="btnSHAKE256">
741+
<Properties>
742+
<Property name="text" type="java.lang.String" value="SHAKE256"/>
743+
</Properties>
744+
<Events>
745+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSHAKE256ActionPerformed"/>
746+
</Events>
747+
</Component>
732748
<Component class="javax.swing.JButton" name="btnHashRIPEMD128">
733749
<Properties>
734750
<Property name="text" type="java.lang.String" value="RIPEMD128"/>
@@ -2205,7 +2221,7 @@
22052221
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
22062222
</Group>
22072223
</Group>
2208-
<EmptySpace pref="413" max="32767" attributes="0"/>
2224+
<EmptySpace pref="429" max="32767" attributes="0"/>
22092225
</Group>
22102226
</Group>
22112227
</DimensionLayout>
@@ -2379,7 +2395,7 @@
23792395
<Component id="lblRadix32" alignment="3" min="-2" max="-2" attributes="0"/>
23802396
<Component id="btnRadix32Copy" alignment="3" min="-2" max="-2" attributes="0"/>
23812397
</Group>
2382-
<EmptySpace pref="494" max="32767" attributes="0"/>
2398+
<EmptySpace pref="510" max="32767" attributes="0"/>
23832399
</Group>
23842400
</Group>
23852401
</DimensionLayout>

0 commit comments

Comments
 (0)