Skip to content

Instantly share code, notes, and snippets.

Jeongjin Kim kimjj81

Block or report user

Report or block kimjj81

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PBKDF2withHmacSHA1.java
public static String makePasswordHash(String text) {
byte[] salt = "yoursalt".getBytes(Charsets.UTF_8);
try {
char[] chars = text.toCharArray();
final int iterations = 10;
// Generate a 256-bit key
final int outputKeyLength = 256;
@kimjj81
kimjj81 / PBKDF2.m
Created Apr 30, 2018
PBKDF2 Objective-c
View PBKDF2.m
#import <CommonCrypto/CommonCrypto.h>
+ (NSString*)onewayHash:(NSString *)text {
NSMutableData *key = [NSMutableData dataWithLength:kCCKeySizeAES256];
NSString *password = text;
NSString* saltText = @"salt";
NSData* salt = [saltText dataUsingEncoding:NSUTF8StringEncoding];
int result = CCKeyDerivationPBKDF(kCCPBKDF2, // algorithm
@kimjj81
kimjj81 / PasswordUtils.java
Created Apr 30, 2018 — forked from ToastShaman/PasswordUtils.java
A utility class for hashing passwords using PBKDF2 with BouncyCastle.
View PasswordUtils.java
package com.zuhlke.lsapi;
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.digests.SHA3Digest;
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.prng.DigestRandomGenerator;
import java.util.Base64;
@kimjj81
kimjj81 / UInt_extension.swift
Last active Feb 26, 2018
Convert UInt to UInt8(byte) Array in swift.
View UInt_extension.swift
protocol UIntToBytesConvertable {
var toBytes: [UInt8] { get }
}
extension UIntToBytesConvertable {
func toByteArr<T: BinaryInteger>(endian: T, count: Int) -> [UInt8] {
var _endian = endian
let bytePtr = withUnsafePointer(to: &_endian) {
$0.withMemoryRebound(to: UInt8.self, capacity: count) {
UnsafeBufferPointer(start: $0, count: count)
@kimjj81
kimjj81 / Save CGImage
Last active Sep 19, 2017
resize uiimage
View Save CGImage
void CGImageWriteToFile(CGImageRef image, NSString *path) {
CFURLRef url = (__bridge CFURLRef) [NSURL fileURLWithPath:path];
CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL);
CGImageDestinationAddImage(destination, image, nil);
if (!CGImageDestinationFinalize(destination)) {
NSLog(@"Failed to write image to %@", path);
}
}
You can’t perform that action at this time.