savfx-utils

1.0.32 • Public • Published

sav-utils

sav utils library

LicenseBuild Status

npm

NPM version

php

Latest Stable Version Code Climate Coverage Status Coveralls Coverage Status

CaseConvert

use SavUtil\CaseConvert;

CaseConvert::convert('camel', 'HelloWorld'); // helloWorld
CaseConvert::convert('pascal', 'Hello-World'); // HelloWorld
CaseConvert::convert('snake', 'HelloWorld'); // hello_world
CaseConvert::convert('hyphen', 'HelloWorld'); // hello-world

// same as above
CaseConvert::pascalCase('HelloWorld');
CaseConvert::pascalCase('Hello-World');
CaseConvert::snakeCase('HelloWorld');
CaseConvert::hyphenCase('HelloWorld');

DateTime

use SavUtil\DateTime;

DateTime::localTime();
DateTime::utcTime();
DateTime::localToUtc();
DateTime::utcToLocal();

Request

use SavUtil\Request;

$res = Request::fetch('http://example.com');
$res->status == 200;
is_array($res->headers);
is_string($res->response);

Request::fetch(array(
    'url' => 'http://example.com',
    'data' => array(),
    'headers' => array(),
    'options' => array(
        // default Options
        'timeout' => 10,
        'connect_timeout' => 10,
        'useragent' => 'curl', // ua
        'type' => 'GET', // method
        'dataType' => '', // empty|json
        'assoc' => true,  // json assoc array
        'filename' => false, // save file
        'verify' => false, // ssl verify
        'verifyname' => false, // ssl verifyname
    ),
));

Request::fetchAll(array(
    "requestA" => array(
        "url" => 'http://example.com',
        "headers" => array(),
        "data" => array(),
        "options" => array(),
    ),
    "requestB" => array(
        "url" => 'http://example.com',
        "headers" => array(),
        "data" => array(),
        "options" => array(),
    ),
), array(
    "timeout" => 20,
));

go

密码散列

  • passwd.Create
    • 类似php的password_hash
    • 目前只提供bcrypt算法
  • passwd.Verify
    • 类似php的password_verify
  • passwd.IsCurrent
    • 类似php的password_needs_rehash
    • 由于只有一个bcrypt所以暂时没用
package main

import (
  "github.com/savgo/sav-util/passwd"
  "fmt"
)

func main() {
  plaintext := "password"
  pwd, _ := passwd.Create(plaintext)
  isValid, _ := passwd.Verify(plaintext, pwd)
  fmt.Println(pwd) // $2a$08$...
  fmt.Println(len(pwd)) // 60
  fmt.Println(isValid) // true
}

Readme

Keywords

none

Package Sidebar

Install

npm i savfx-utils

Weekly Downloads

0

Version

1.0.32

License

MIT

Unpacked Size

116 kB

Total Files

54

Last publish

Collaborators

  • jetiny