Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 7617b0e

Browse files
authored
Add function isHexa (#74)
1 parent 698552e commit 7617b0e

File tree

1 file changed

+24
-0
lines changed
  • SecurityAPICommons/src/main/java/com/genexus/securityapicommons/encoders

1 file changed

+24
-0
lines changed

SecurityAPICommons/src/main/java/com/genexus/securityapicommons/encoders/HexaEncoder.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,29 @@ public String fromHexa(String stringHexa) {
6464
this.error.cleanError();
6565
return result;
6666
}
67+
68+
public boolean isHexa(String input)
69+
{
70+
this.error.cleanError();
71+
try
72+
{
73+
Hex.decode(fixString(input));
74+
}catch(Exception e)
75+
{
76+
return false;
77+
}
78+
return true;
79+
}
80+
81+
private String fixString(String input)
82+
{
83+
if(!input.contains("-"))
84+
{
85+
return input;
86+
}else {
87+
String inputStr = input.replace("-", "");
88+
return inputStr;
89+
}
90+
}
6791

6892
}

0 commit comments

Comments
 (0)