XANNYANAXIUM FILE MANAGER

Navigate and manage your files

Current Directory
Upload File
Standard Upload
Advanced Upload

Status: No file selected

Create New
Name Type Size Modified Permission Actions
/ .. Directory — 2025-05-23 05:57:18 0755
/ wp-admin Directory — 2026-08-24 09:01:10 0755
/ wp-content Directory — 2026-09-23 15:34:11 0755
/ wp-includes Directory — 2026-09-23 15:34:04 0755
.htaccess HTACCESS 1.92 KB 2026-05-07 22:43:39 0644
.htaccess.bk BK 1.15 KB 2025-11-21 07:04:52 0644
.htaccess_old HTACCESS_OLD 1.80 KB 2025-11-21 07:14:55 0644
.user.ini INI 9 bytes 2026-01-05 06:16:59 0644
atomlib.php PHP 0 bytes 2026-09-22 09:09:48 0644
default.php PHP 15.99 KB 2025-05-23 12:16:32 0644
edits.php PHP 0 bytes 2026-09-22 08:49:13 0644
index.php PHP 1.30 KB 2026-09-22 06:21:28 0644
license.txt TXT 19.44 KB 2026-08-20 12:39:46 0644
phpinfo.php PHP 20 bytes 2025-05-23 05:57:32 0644
readme.html HTML 7.23 KB 2026-09-18 01:39:40 0644
robots.txt TXT 405 bytes 2026-09-22 07:12:19 0644
wp-activate.php PHP 7.54 KB 2026-08-20 12:39:46 0644
wp-blog-header.php PHP 351 bytes 2025-05-23 12:16:32 0644
wp-comments-post.php PHP 2.27 KB 2025-05-23 12:16:32 0644
wp-config-sample.php PHP 46 bytes 2026-09-23 15:34:06 0644
wp-config.php PHP 3.53 KB 2025-11-21 07:39:35 0644
wp-cron.php PHP 5.49 KB 2025-05-23 12:16:32 0644
wp-links-opml.php PHP 2.43 KB 2025-12-03 12:55:28 0644
wp-load.php PHP 3.84 KB 2025-05-23 12:16:32 0644
wp-login.php PHP 51.30 KB 2026-08-20 12:39:46 0644
wp-mail.php PHP 8.52 KB 2025-12-03 12:55:30 0644
wp-postnews.php PHP 12.59 KB 2026-09-23 09:22:15 0644
wp-settings.php PHP 32.38 KB 2026-08-20 12:39:46 0644
wp-signup.php PHP 34.26 KB 2026-08-20 12:39:46 0644
wp-sx9a.php PHP 0 bytes 2026-09-22 08:49:04 0644
wp-trackback.php PHP 5.27 KB 2026-08-20 12:39:46 0644
xmlrpc.php PHP 3.13 KB 2025-05-23 12:16:32 0644

Dir : /opt/go/pkg/mod/golang.org/x/crypto@v0.18.0/bcrypt/
Server: Linux in-mum-web1754.main-hosting.eu 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
IP: 77.37.46.203
Choose File :
Url:
Dir : //opt/go/pkg/mod/golang.org/x/crypto@v0.18.0/bcrypt/bcrypt_test.go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package bcrypt

import (
	"bytes"
	"fmt"
	"testing"
)

func TestBcryptingIsEasy(t *testing.T) {
	pass := []byte("mypassword")
	hp, err := GenerateFromPassword(pass, 0)
	if err != nil {
		t.Fatalf("GenerateFromPassword error: %s", err)
	}

	if CompareHashAndPassword(hp, pass) != nil {
		t.Errorf("%v should hash %s correctly", hp, pass)
	}

	notPass := "notthepass"
	err = CompareHashAndPassword(hp, []byte(notPass))
	if err != ErrMismatchedHashAndPassword {
		t.Errorf("%v and %s should be mismatched", hp, notPass)
	}
}

func TestBcryptingIsCorrect(t *testing.T) {
	pass := []byte("allmine")
	salt := []byte("XajjQvNhvvRt5GSeFk1xFe")
	expectedHash := []byte("$2a$10$XajjQvNhvvRt5GSeFk1xFeyqRrsxkhBkUiQeg0dt.wU1qD4aFDcga")

	hash, err := bcrypt(pass, 10, salt)
	if err != nil {
		t.Fatalf("bcrypt blew up: %v", err)
	}
	if !bytes.HasSuffix(expectedHash, hash) {
		t.Errorf("%v should be the suffix of %v", hash, expectedHash)
	}

	h, err := newFromHash(expectedHash)
	if err != nil {
		t.Errorf("Unable to parse %s: %v", string(expectedHash), err)
	}

	// This is not the safe way to compare these hashes. We do this only for
	// testing clarity. Use bcrypt.CompareHashAndPassword()
	if err == nil && !bytes.Equal(expectedHash, h.Hash()) {
		t.Errorf("Parsed hash %v should equal %v", h.Hash(), expectedHash)
	}
}

func TestVeryShortPasswords(t *testing.T) {
	key := []byte("k")
	salt := []byte("XajjQvNhvvRt5GSeFk1xFe")
	_, err := bcrypt(key, 10, salt)
	if err != nil {
		t.Errorf("One byte key resulted in error: %s", err)
	}
}

func TestTooLongPasswordsWork(t *testing.T) {
	salt := []byte("XajjQvNhvvRt5GSeFk1xFe")
	// One byte over the usual 56 byte limit that blowfish has
	tooLongPass := []byte("012345678901234567890123456789012345678901234567890123456")
	tooLongExpected := []byte("$2a$10$XajjQvNhvvRt5GSeFk1xFe5l47dONXg781AmZtd869sO8zfsHuw7C")
	hash, err := bcrypt(tooLongPass, 10, salt)
	if err != nil {
		t.Fatalf("bcrypt blew up on long password: %v", err)
	}
	if !bytes.HasSuffix(tooLongExpected, hash) {
		t.Errorf("%v should be the suffix of %v", hash, tooLongExpected)
	}
}

type InvalidHashTest struct {
	err  error
	hash []byte
}

var invalidTests = []InvalidHashTest{
	{ErrHashTooShort, []byte("$2a$10$fooo")},
	{ErrHashTooShort, []byte("$2a")},
	{HashVersionTooNewError('3'), []byte("$3a$10$sssssssssssssssssssssshhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")},
	{InvalidHashPrefixError('%'), []byte("%2a$10$sssssssssssssssssssssshhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")},
	{InvalidCostError(32), []byte("$2a$32$sssssssssssssssssssssshhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")},
}

func TestInvalidHashErrors(t *testing.T) {
	check := func(name string, expected, err error) {
		if err == nil {
			t.Errorf("%s: Should have returned an error", name)
		}
		if err != nil && err != expected {
			t.Errorf("%s gave err %v but should have given %v", name, err, expected)
		}
	}
	for _, iht := range invalidTests {
		_, err := newFromHash(iht.hash)
		check("newFromHash", iht.err, err)
		err = CompareHashAndPassword(iht.hash, []byte("anything"))
		check("CompareHashAndPassword", iht.err, err)
	}
}

func TestUnpaddedBase64Encoding(t *testing.T) {
	original := []byte{101, 201, 101, 75, 19, 227, 199, 20, 239, 236, 133, 32, 30, 109, 243, 30}
	encodedOriginal := []byte("XajjQvNhvvRt5GSeFk1xFe")

	encoded := base64Encode(original)

	if !bytes.Equal(encodedOriginal, encoded) {
		t.Errorf("Encoded %v should have equaled %v", encoded, encodedOriginal)
	}

	decoded, err := base64Decode(encodedOriginal)
	if err != nil {
		t.Fatalf("base64Decode blew up: %s", err)
	}

	if !bytes.Equal(decoded, original) {
		t.Errorf("Decoded %v should have equaled %v", decoded, original)
	}
}

func TestCost(t *testing.T) {
	suffix := "XajjQvNhvvRt5GSeFk1xFe5l47dONXg781AmZtd869sO8zfsHuw7C"
	for _, vers := range []string{"2a", "2"} {
		for _, cost := range []int{4, 10} {
			s := fmt.Sprintf("$%s$%02d$%s", vers, cost, suffix)
			h := []byte(s)
			actual, err := Cost(h)
			if err != nil {
				t.Errorf("Cost, error: %s", err)
				continue
			}
			if actual != cost {
				t.Errorf("Cost, expected: %d, actual: %d", cost, actual)
			}
		}
	}
	_, err := Cost([]byte("$a$a$" + suffix))
	if err == nil {
		t.Errorf("Cost, malformed but no error returned")
	}
}

func TestCostValidationInHash(t *testing.T) {
	if testing.Short() {
		return
	}

	pass := []byte("mypassword")

	for c := 0; c < MinCost; c++ {
		p, _ := newFromPassword(pass, c)
		if p.cost != DefaultCost {
			t.Errorf("newFromPassword should default costs below %d to %d, but was %d", MinCost, DefaultCost, p.cost)
		}
	}

	p, _ := newFromPassword(pass, 14)
	if p.cost != 14 {
		t.Errorf("newFromPassword should default cost to 14, but was %d", p.cost)
	}

	hp, _ := newFromHash(p.Hash())
	if p.cost != hp.cost {
		t.Errorf("newFromHash should maintain the cost at %d, but was %d", p.cost, hp.cost)
	}

	_, err := newFromPassword(pass, 32)
	if err == nil {
		t.Fatalf("newFromPassword: should return a cost error")
	}
	if err != InvalidCostError(32) {
		t.Errorf("newFromPassword: should return cost error, got %#v", err)
	}
}

func TestCostReturnsWithLeadingZeroes(t *testing.T) {
	hp, _ := newFromPassword([]byte("abcdefgh"), 7)
	cost := hp.Hash()[4:7]
	expected := []byte("07$")

	if !bytes.Equal(expected, cost) {
		t.Errorf("single digit costs in hash should have leading zeros: was %v instead of %v", cost, expected)
	}
}

func TestMinorNotRequired(t *testing.T) {
	noMinorHash := []byte("$2$10$XajjQvNhvvRt5GSeFk1xFeyqRrsxkhBkUiQeg0dt.wU1qD4aFDcga")
	h, err := newFromHash(noMinorHash)
	if err != nil {
		t.Fatalf("No minor hash blew up: %s", err)
	}
	if h.minor != 0 {
		t.Errorf("Should leave minor version at 0, but was %d", h.minor)
	}

	if !bytes.Equal(noMinorHash, h.Hash()) {
		t.Errorf("Should generate hash %v, but created %v", noMinorHash, h.Hash())
	}
}

func BenchmarkEqual(b *testing.B) {
	b.StopTimer()
	passwd := []byte("somepasswordyoulike")
	hash, _ := GenerateFromPassword(passwd, DefaultCost)
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		CompareHashAndPassword(hash, passwd)
	}
}

func BenchmarkDefaultCost(b *testing.B) {
	b.StopTimer()
	passwd := []byte("mylongpassword1234")
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		GenerateFromPassword(passwd, DefaultCost)
	}
}

// See Issue https://github.com/golang/go/issues/20425.
func TestNoSideEffectsFromCompare(t *testing.T) {
	source := []byte("passw0rd123456")
	password := source[:len(source)-6]
	token := source[len(source)-6:]
	want := make([]byte, len(source))
	copy(want, source)

	wantHash := []byte("$2a$10$LK9XRuhNxHHCvjX3tdkRKei1QiCDUKrJRhZv7WWZPuQGRUM92rOUa")
	_ = CompareHashAndPassword(wantHash, password)

	got := bytes.Join([][]byte{password, token}, []byte(""))
	if !bytes.Equal(got, want) {
		t.Errorf("got=%q want=%q", got, want)
	}
}

func TestPasswordTooLong(t *testing.T) {
	_, err := GenerateFromPassword(make([]byte, 73), 1)
	if err != ErrPasswordTooLong {
		t.Errorf("unexpected error: got %q, want %q", err, ErrPasswordTooLong)
	}
}