Skip to content

Instantly share code, notes, and snippets.

View amayatsky's full-sized avatar

Alexander Mayatsky amayatsky

  • MTS - Mobile TeleSystems PJSC
  • Moscow
View GitHub Profile
@amayatsky
amayatsky / XORCrypt.gradle
Last active March 13, 2019 09:23 — forked from premnirmal/XORCrypt.java
Simple yet effective XOR encryption
private static int[] encrypt(String str, String key) {
int[] output = new int[str.length()];
for(int i = 0; i < str.length(); i++) {
int o = ((int) str.charAt(i) ^ (int) key.charAt(i % (key.length() - 1))) + (char)('0');
output[i] = o;
}
return output;
}
@amayatsky
amayatsky / URL+Zip.swift
Last active June 9, 2018 07:01 — forked from marcprux/NSURL+Zip.swift
Categories on URL and Data to create a zip archive without any external dependencies
public extension URL {
/// Creates a zip archive of the file/folder represented by this URL and returns a references to the zipped file
///
/// - parameter dest: the destination URL; if nil, the destination will be this URL with ".zip" appended
func zip(dest: URL? = nil) throws -> URL {
let destURL = dest ?? self.appendingPathExtension("zip")
let fm = FileManager.default
var isDir: ObjCBool = false
@amayatsky
amayatsky / NSString+KBAdditions.swift
Last active February 22, 2019 13:28 — forked from mkubenka/NSString+KBAdditions.h
Rewritten for Swift + UIButton extension
//
// NSString+KBAdditions.swift
//
// Created by Alexander Mayatsky on 16/03/16.
//
// Original code from http://stackoverflow.com/a/4383281/463892 & http://stackoverflow.com/a/18951386
//
import Foundation
import UIKit