Hash UTF-8 text
GET
https://api.testingapis.com/api/utils/hashParameters 2
| Name | Type | Description |
|---|---|---|
text | query · string | Text to hash. Default empty. Default: "". |
algorithm | query · string | md5, sha1, sha256 (default), sha384 or sha512. Case-insensitive. Default: "sha256". |
Responses
- 200
- Success.
- 400
- Unknown algorithm.
Example
Request
curl -X GET "https://api.testingapis.com/api/utils/hash?text=hello&algorithm=sha256"Response200 OK
{
"input": "hello",
"algorithm": "sha256",
"hex": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
"base64": "LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="
}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/utils/hash?text=hello&algorithm=sha256");
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"GET",
"https://api.testingapis.com/api/utils/hash?text=hello&algorithm=sha256",
allow_redirects=False,
)
print(response.status_code, response.text)Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/utils/hash?text=hello&algorithm=sha256"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}