Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gamutils/src/main/java/com/genexus/gam/GamUtilsEO.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public static String base64ToBase64Url(String base64) {

public static String base64ToHexa(String base64) { return Encoding.base64ToHexa(base64); }

public static boolean isHexadecimal(String hexa) { return Encoding.isHexa(hexa); }

//**PKCE**//

public static String pkce_create(int len, String option) { return Pkce.create(len, option); }
Expand Down
12 changes: 12 additions & 0 deletions gamutils/src/main/java/com/genexus/gam/utils/Encoding.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,16 @@ public static String base64ToHexa(String base64)
return "";
}
}

public static boolean isHexa(String hexa)
{
try {
Hex.decode(hexa);
}catch (Exception e)
{
logger.error("isHexa", e);
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,19 @@ private static String b64ToHexa(String base64) {
}
}

@Test
public void testIsHexa()
{
int i = 0;
do {
String randomHexa = GamUtilsEO.randomHexaBits(128);
boolean hexa = GamUtilsEO.isHexadecimal(randomHexa);
Assert.assertTrue("testIsHexa_true", hexa);

String randomAlphanumeric = GamUtilsEO.randomAlphanumeric(128);
boolean notHexa = GamUtilsEO.isHexadecimal(randomAlphanumeric);
Assert.assertFalse("testIsHexa_false", notHexa);
i++;
} while (i < 50);
}
}
Loading