-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #673 from CROSSINGTUD/fix/issue-271
Add test case from #271
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>example</groupId> | ||
<artifactId>Issue271</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>issue271</name> | ||
|
||
<properties> | ||
<kotlin.version>2.0.0</kotlin.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
<version>${kotlin.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<version>${kotlin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<phase>process-sources</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<goals> | ||
<goal>test-compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
<configuration> | ||
<source>11</source> | ||
<target>11</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
17 changes: 17 additions & 0 deletions
17
CryptoAnalysisTargets/KotlinExamples/Issue271/src/main/java/example/Issue271Kotlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package example; | ||
|
||
import java.security.MessageDigest | ||
|
||
fun main() { | ||
testFail("abc123ABC") | ||
testOk("abc123ABC") | ||
} | ||
|
||
fun testFail(input: String) { | ||
val someManipulation = input.substring(0, 2) | ||
MessageDigest.getInstance("SHA-256").digest(someManipulation.toByteArray()) | ||
} | ||
|
||
fun testOk(input: String) { | ||
MessageDigest.getInstance("SHA-256").digest(input.toByteArray()) | ||
} |
21 changes: 21 additions & 0 deletions
21
CryptoAnalysisTargets/KotlinExamples/issue271/src/main/java/example/Issue271Java.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package example; | ||
|
||
import java.security.MessageDigest; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
public class Issue271Java { | ||
|
||
public static void main(String [] args) throws NoSuchAlgorithmException { | ||
testFail("abc123ABC"); | ||
testOk("abc123ABC"); | ||
} | ||
|
||
public static void testFail(String input) throws NoSuchAlgorithmException { | ||
String someManipulation = input.substring(0, 2); | ||
MessageDigest.getInstance("SHA-256").digest(someManipulation.getBytes()); | ||
} | ||
|
||
public static void testOk(String input) throws NoSuchAlgorithmException { | ||
MessageDigest.getInstance("SHA-256").digest(input.getBytes()); | ||
} | ||
} |